from collections import deque
from typing import List


class Solution:
    def numberOfArithmeticSlices(self, nums: List[int]) -> int:
        n = len(nums)
        cnt = 0
        for k in range(3, n + 1):
            arr = deque()
            left = 0
            right = k - 1
            for i in range(right):
                arr.append(nums[i])
            while right < n:
                if len(arr) >= 2 and nums[right] + arr[-2] != 2 * arr[-1]: break
                arr.append(nums[right])
                if len(arr) > k:
                    arr.popleft()
                    left += 1
                if len(arr) == k:
                    cnt += 1
                right += 1
        return cnt


if __name__ == '__main__':
    s = Solution()
    r = s.numberOfArithmeticSlices([1, 2, 3, 4])
    print(r)
